package com.springboot.demo.service.impl;

import com.springboot.demo.entity.*;
import com.springboot.demo.exception.BusinessException;
import com.springboot.demo.mapper.*;
import com.springboot.demo.service.PanelService;
import com.springboot.demo.service.SceneService;
import com.springboot.demo.utils.Constant;
import com.springboot.demo.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * @author wubc683
 * @desc
 * @date 2021-11-18 17:06
 */
@Service
public class PanelServiceImpl implements PanelService {
    @Autowired
    SceneMapper sceneMapper;
    @Autowired
    InboxMapper inboxMapper;
    @Autowired
    DeviceMapper deviceMapper;
    @Autowired
    PanelMapper panelMapper;
    @Autowired
    MapMapper mapMapper;
    @Autowired
    TableMapper tableMapper;

//    @Override
//    public List<Panel> getAllScenePanelInfo(Long uid, Long sid) {
//        // 检查场景是否属于用户
//        Scene sceneById = sceneMapper.getSceneById(sid);
//        if (!sceneById.getOwnerId().equals(uid)) {
//            throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE);
//        }
//        return sceneMapper.getSceneAllPanels(sid);
//    }

//    @Override
//    public List<Panel> getScenePanelInfo(Long uid, Long pid) {
//        return null;
//    }

//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public void saveScenePanelInfo(Long uid, Long sid, String name) {
//        // 检查场景是否属于用户
//        Scene sceneById = sceneMapper.getSceneById(sid);
//        if (!sceneById.getOwnerId().equals(uid)) {
//            throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE);
//        }
//        // 检查场景仪表盘名字是否重复
//        List<String> sceneAllPanelNames = sceneMapper.getSceneAllPanelNames(sid);
//        if (sceneAllPanelNames.contains(name)) {
//            throw new BusinessException(ResponseResult.SCENE_PANEL_NAME_DUPLICATE);
//        }
//        // 存入数据库
//        Panel scenePanel = new Panel();
//        scenePanel.setName(name);
//        scenePanel.setCreateDate(new Date());
//        scenePanel.setIsDefault(false);
//        sceneMapper.saveScenePanelInfo(scenePanel);
//    }

    @Override
    public List<Panel> getAllPanel(Long uid, Integer type, Long sceneId) {
        if (type.equals(Constant.PanelType.OPERATE_PANEL)) {
            return panelMapper.getAllOperatePanels(uid);
        } else {
            // 校验场景id是否属于用户
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneIdsByUid == null || sceneIdsByUid.size() == 0 || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE);
            }
            return panelMapper.getAllScenePanels(sceneId);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void savePanel(Long uid, Integer type, Long sceneId, String name) {
        if (type.equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘名字是否重复
            List<String> allOperatePanelNames = panelMapper.getAllOperatePanelNames(uid);
            if (allOperatePanelNames != null && allOperatePanelNames.contains(name)) {
                throw new BusinessException(ResponseResult.PANEL_NAME_DUPLICATE);
            }
            // 插入数据库
            Panel panel = new Panel(name, type, new Date(), false);
            panelMapper.savePanel(panel);
            panelMapper.saveUserOperatePanel(uid, panel.getId());
        } else if (type.equals(Constant.PanelType.SCENE_PANEL)) {
            // 校验场景id是否属于用户
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneIdsByUid == null || sceneIdsByUid.size() == 0 || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE);
            }
            // 检查仪表盘名字是否重复
            List<String> allScenePanelNames = panelMapper.getAllScenePanelNames(sceneId);
            if (allScenePanelNames != null && allScenePanelNames.contains(name)) {
                throw new BusinessException(ResponseResult.PANEL_NAME_DUPLICATE);
            }
            // 插入数据库
            Panel panel = new Panel(name, type, new Date(), false);
            panelMapper.savePanel(panel);
            panelMapper.saveScenePanel(sceneId, panel.getId());
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
    }

    @Override
    public void updatePanel(Long uid, Panel panel) {
        // 获取仪表盘类型
        Panel panelById = panelMapper.getPanelById(panel.getId());
        if (panelById == null) {
            throw new BusinessException(ResponseResult.PANEL_NOT_EXISTED);
        }
        if (panelById.getType().equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘是否属于用户
            Long operatePanelUserIdByUidAndPanelId = panelMapper.getOperatePanelUserIdByUidAndPanelId(uid, panel.getId());
            if (operatePanelUserIdByUidAndPanelId == null) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_OPERATE_PANEL);
            }
            // 检查仪表盘名字是否重复
            List<String> allOperatePanelNamesExceptPid = panelMapper.getAllOperatePanelNamesExceptPid(uid, panel.getId());
            if (allOperatePanelNamesExceptPid != null && allOperatePanelNamesExceptPid.contains(panel.getName())) {
                throw new BusinessException(ResponseResult.PANEL_NAME_DUPLICATE);
            }
            // 修改数据库
            panelMapper.updatePanel(panel);
        } else if (panelById.getType().equals(Constant.PanelType.SCENE_PANEL)) {
            // 获取场景id,校验场景id是否属于用户
            Long sceneId = panelMapper.getSceneIdByPanelId(panel.getId());
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneId == null || sceneIdsByUid == null || sceneIdsByUid.size() == 0 || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE_PANEL);
            }
            // 检查仪表盘名字是否重复
            List<String> allScenePanelNamesExceptPid = panelMapper.getAllScenePanelNamesExceptPid(sceneId, panel.getId());
            if (allScenePanelNamesExceptPid != null && allScenePanelNamesExceptPid.contains(panel.getName())) {
                throw new BusinessException(ResponseResult.PANEL_NAME_DUPLICATE);
            }
            // 修改数据库
            panelMapper.updatePanel(panel);
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deletePanel(Long uid, Long pid) {
        // 获取仪表盘类型
        Panel panelById = panelMapper.getPanelById(pid);
        if (panelById == null) {
            throw new BusinessException(ResponseResult.PANEL_NOT_EXISTED);
        }
        if (panelById.getType().equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘是否属于用户
            Long operatePanelUserIdByUidAndPanelId = panelMapper.getOperatePanelUserIdByUidAndPanelId(uid, pid);
            if (operatePanelUserIdByUidAndPanelId == null) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_OPERATE_PANEL);
            }
            // 检查是否是默认仪表盘
            if (panelById.getIsDefault().equals(true)) {
                throw new BusinessException(ResponseResult.DEFAULT_PANEL_CAN_NOT_DELETE);
            }
            // 删除仪表盘
            panelMapper.deleteOperatePanelByPanelId(pid);
            panelMapper.deletePanelById(pid);
            // 删除仪表盘中地图，地图关联组件，报表
            panelMapper.deletePanelTableByPanelId(pid);
            Long mapId = panelMapper.getPanelMapIdByPanelId(pid);
            if(mapId != null){
               mapMapper.deleteMapLink(mapId);
            }
            panelMapper.deletePanelMapByPanelId(pid);
        } else if (panelById.getType().equals(Constant.PanelType.SCENE_PANEL)) {
            // 获取场景id,校验场景id是否属于用户
            Long sceneId = panelMapper.getSceneIdByPanelId(pid);
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneId == null || sceneIdsByUid == null || sceneIdsByUid.size() == 0 || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE_PANEL);
            }
            // 检查是否是默认仪表盘
            if (panelById.getIsDefault().equals(true)) {
                throw new BusinessException(ResponseResult.DEFAULT_PANEL_CAN_NOT_DELETE);
            }
            // 删除仪表盘
            panelMapper.deleteScenePanelByPanelId(pid);
            panelMapper.deletePanelById(pid);
            // 删除仪表盘中地图，报表
            panelMapper.deletePanelTableByPanelId(pid);
            panelMapper.deletePanelMapByPanelId(pid);
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Panel getPanelComponent(Long uid, Long pid) {
        // 获取仪表盘信息
        Panel panel = panelMapper.getPanelById(pid);
        if (panel == null) {
            throw new BusinessException(ResponseResult.PANEL_NOT_EXISTED);
        }
        if (panel.getType().equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘是否属于用户
            Long operatePanelUserIdByUidAndPanelId = panelMapper.getOperatePanelUserIdByUidAndPanelId(uid, pid);
            if (operatePanelUserIdByUidAndPanelId == null) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_OPERATE_PANEL);
            }
            //获取仪表盘中地图组件,以及联动组件
            MapData mapData = panelMapper.getPanelMapByPanelId(pid);
            // 获取地图组件位置
            panel.setMapData(mapData);
            if (mapData != null) {
                ComponentPosition mapLinkDataByMapId = mapMapper.getMapLinkDataByMapId(mapData.getId());
                MapLinkedData mapLinkedData = new MapLinkedData();
                if(mapLinkDataByMapId != null){
                    mapLinkedData.setMapId(mapData.getId());
                    mapLinkedData.setPosition(mapLinkDataByMapId);
                    panel.setMapLinkedData(mapLinkedData);
                }
            }
        } else if (panel.getType().equals(Constant.PanelType.SCENE_PANEL)) {
            // 获取场景id,校验场景id是否属于用户
            Long sceneId = panelMapper.getSceneIdByPanelId(pid);
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneId == null || sceneIdsByUid == null || sceneIdsByUid.size() == 0
                    || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE_PANEL);
            }
            //获取仪表盘中地图组件(没有联动组件)
            MapData mapData = panelMapper.getPanelMapByPanelId(pid);
            panel.setMapData(mapData);
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
        // 获取仪表盘中报表组件
        List<TableData> panelTablesByPanelId = panelMapper.getPanelTablesByPanelId(pid);
        panel.setTableData(panelTablesByPanelId);
//         获取场景组态图组件
//        SceneGraph panelSceneGraphByPanelId = panelMapper.getPanelSceneGraphByPanelId(pid);
//        panel.setSceneGraphIdList(panelSceneGraphByPanelId);
        return panel;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updatePanelComponent(Long uid, List<PanelComponent> componentList) {
        if (componentList.size() == 0) {
            return;
        }
        // 校验所有的仪表盘是否一样
        Integer panelType = componentList.get(0).getPanelType();
        Long panelId = componentList.get(0).getPanelId();
        for (int i = 1; i < componentList.size(); i++) {
            if (!componentList.get(i).getPanelType().equals(panelType)
                    || !componentList.get(i).getPanelId().equals(panelId)) {
                throw new BusinessException(ResponseResult.COMPONENT_BELONG_TO_DIFFERENT_PANEL);
            }
        }
        // 仪表盘分类校验
        Long sceneId = null;
        if (componentList.get(0).getPanelType().equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘是否属于用户
            Long operatePanelUserIdByUidAndPanelId = panelMapper.getOperatePanelUserIdByUidAndPanelId(uid,
                    componentList.get(0).getPanelId());
            if (operatePanelUserIdByUidAndPanelId == null) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_OPERATE_PANEL);
            }
        } else if (componentList.get(0).getPanelType().equals(Constant.PanelType.SCENE_PANEL)) {
            // 获取场景id,校验场景id是否属于用户
            sceneId = panelMapper.getSceneIdByPanelId(componentList.get(0).getPanelId());
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneId == null || sceneIdsByUid == null || sceneIdsByUid.size() == 0
                    || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE_PANEL);
            }
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
        // 组件分类校验
        for (int i = 0; i < componentList.size(); i++) {
            // 校验组件位置
            checkComponentPosition(componentList.get(i).getPosition());
            if (componentList.get(i).getComponentType().equals(Constant.ComponentType.TABLE)) {
                // 检查报表是否属于用户
                Long tableOwnerIdByTableId =
                        tableMapper.getTableOwnerIdByTableId(componentList.get(i).getComponentId());
                if (tableOwnerIdByTableId == null || !tableOwnerIdByTableId.equals(uid)) {
                    throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_TABLE);
                }
                panelMapper.updatePanelTable(componentList.get(i));
            } else if (componentList.get(i).getComponentType().equals(Constant.ComponentType.MAP)) {
                // 检查仪表盘是否已包含地图
                MapData panelMapByPanelId = panelMapper.getPanelMapByPanelId(componentList.get(i).getPanelId());
                if (panelMapByPanelId == null) {
                    throw new BusinessException(ResponseResult.PANEL_NOT_HAVE_MAP);
                }
                panelMapper.updatePanelMap(componentList.get(i));
            } else if (componentList.get(i).getComponentType().equals(Constant.ComponentType.MAP_LINK)) {
                // 检查是否存在地图组件
                Long mapId = panelMapper.getPanelMapIdByPanelId(componentList.get(i).getPanelId());
                if (mapId == null) {
                    throw new BusinessException(ResponseResult.PANEL_NOT_HAVE_MAP_LINK);
                }
                mapMapper.updateMapLink(mapId, componentList.get(i));
            } else {
                throw new BusinessException(ResponseResult.PANEL_COMPONENT_TYPE_ERROR);
            }
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addPanelComponent(Long uid, PanelComponent component) {
        // 仪表盘分类校验
        Long sceneId = null;
        if (component.getPanelType().equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘是否属于用户
            Long operatePanelUserIdByUidAndPanelId = panelMapper.getOperatePanelUserIdByUidAndPanelId(uid,
                    component.getPanelId());
            if (operatePanelUserIdByUidAndPanelId == null) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_OPERATE_PANEL);
            }
        } else if (component.getPanelType().equals(Constant.PanelType.SCENE_PANEL)) {
            // 获取场景id,校验场景id是否属于用户
            sceneId = panelMapper.getSceneIdByPanelId(component.getPanelId());
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneId == null || sceneIdsByUid == null || sceneIdsByUid.size() == 0
                    || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE_PANEL);
            }
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
        // 校验组件位置
        checkComponentPosition(component.getPosition());
        // 组件分类校验
        if (component.getComponentType().equals(Constant.ComponentType.TABLE)) {
            // 检查报表是否属于用户
            Long tableOwnerIdByTableId = tableMapper.getTableOwnerIdByTableId(component.getComponentId());
            if (tableOwnerIdByTableId == null || !tableOwnerIdByTableId.equals(uid)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_TABLE);
            }
            // 仪表盘是否已经包含此报表
            List<Long> panelTableIdsByPanelId = panelMapper.getPanelTableIdsByPanelId(component.getPanelId());
            if (panelTableIdsByPanelId != null && panelTableIdsByPanelId.contains(component.getComponentId())) {
                throw new BusinessException(ResponseResult.PANEL_ALREADY_HAS_THIS_TABLE);
            }
            panelMapper.savePanelTable(component);
        } else if (component.getComponentType().equals(Constant.ComponentType.MAP)) {
            // 检查仪表盘是否已包含地图
            MapData panelMapByPanelId = panelMapper.getPanelMapByPanelId(component.getPanelId());
            if (panelMapByPanelId != null) {
                throw new BusinessException(ResponseResult.PANEL_ALREADY_HAS_THIS_MAP);
            }
            // 创建默认地图,运营仪表盘初始化包含中国地图和场景仪表盘地图初始化经纬度为场景中设备的经纬度
            MapData mapData = new MapData();
            mapData.setDisperseType(Constant.MapDisperseType.POINT_AGGREGATE);
            mapData.setColor(Constant.MapColor.WHITE);
            if (component.getPanelType().equals(Constant.PanelType.OPERATE_PANEL)) {
                // 深圳经纬度
                mapData.setLongitude(114.044627);
                mapData.setLatitude(22.640208);
                mapData.setScale(12);
            } else {
                List<Device> deviceAddrBySceneId = sceneMapper.getDeviceAddrBySceneId(sceneId);
                // 用场景中任意设备的经纬度作为场景的位置
                if (deviceAddrBySceneId != null && deviceAddrBySceneId.size() != 0) {
                    mapData.setLongitude(deviceAddrBySceneId.get(0).getLongitude());
                    mapData.setLatitude(deviceAddrBySceneId.get(0).getLatitude());
                    mapData.setScale(14);
                } else {
                    // 深圳经纬度
                    mapData.setLongitude(114.044627);
                    mapData.setLatitude(22.640208);
                    mapData.setScale(12);
                }
            }
            mapMapper.saveMap(mapData);
            component.setComponentId(mapData.getId());
            panelMapper.savePanelMap(component);
        } else if (component.getComponentType().equals(Constant.ComponentType.MAP_LINK)) {
            // 检查是否存在地图组件
            Long mapId = panelMapper.getPanelMapIdByPanelId(component.getPanelId());
            if (mapId == null) {
                throw new BusinessException(ResponseResult.MAP_LINK_CAN_NOT_CREATE_WITHOUT_MAP);
            }
            // 检查是否存在地图关联组件
            Long panelMapLinkDataByPanelId = panelMapper.getPanelMapLinkDataByPanelId(component.getPanelId());
            if (panelMapLinkDataByPanelId != null) {
                throw new BusinessException(ResponseResult.PANEL_ALREADY_HAS_THIS_MAP_LINK);
            }
            mapMapper.saveMapLink(mapId, component);
        } else {
            throw new BusinessException(ResponseResult.PANEL_COMPONENT_TYPE_ERROR);
        }
    }

    /**
     * 校验组件位置信息
     *
     * @param position
     * @return: void
     */
    private void checkComponentPosition(ComponentPosition position) {
        if (position.getLeftPos().compareTo(Constant.ComponentPos.LEFT_LIMIT) < 0
//                || position.getLeftPos().compareTo(position.getRightPos()) >= 0
                || position.getRightPos().compareTo(Constant.ComponentPos.RIGHT_LIMIT) > 0
                || position.getTopPos().compareTo(Constant.ComponentPos.TOP_LIMIT) < 0
//                || position.getTopPos().compareTo(position.getDownPos()) >= 0
                || position.getDownPos().compareTo(Constant.ComponentPos.DOWN_LIMIT) > 0) {
            throw new BusinessException(ResponseResult.PANEL_COMPONENT_POS_EXCEED_LIMIT);
        }
    }

    @Override
    public void deletePanelComponent(Long uid, PanelComponent component) {
        // 仪表盘分类校验
        Panel panelById = panelMapper.getPanelById(component.getPanelId());
        if (panelById == null) {
            throw new BusinessException(ResponseResult.PANEL_NOT_EXISTED);
        }
        Long sceneId = null;
        if (panelById.getType().equals(Constant.PanelType.OPERATE_PANEL)) {
            // 检查仪表盘是否属于用户
            Long operatePanelUserIdByUidAndPanelId = panelMapper.getOperatePanelUserIdByUidAndPanelId(uid,
                    component.getPanelId());
            if (operatePanelUserIdByUidAndPanelId == null) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_OPERATE_PANEL);
            }
        } else if (panelById.getType().equals(Constant.PanelType.SCENE_PANEL)) {
            // 获取场景id,校验场景id是否属于用户
            sceneId = panelMapper.getSceneIdByPanelId(component.getPanelId());
            List<Long> sceneIdsByUid = sceneMapper.getSceneIdsByUid(uid);
            if (sceneId == null || sceneIdsByUid == null || sceneIdsByUid.size() == 0
                    || !sceneIdsByUid.contains(sceneId)) {
                throw new BusinessException(ResponseResult.USER_DO_NOT_HAVE_THIS_SCENE_PANEL);
            }
        } else {
            throw new BusinessException(ResponseResult.PANEL_TYPE_ERROR);
        }
        // 组件分类校验
        if (component.getComponentType().equals(Constant.ComponentType.TABLE)) {
            // 仪表盘是否包含此报表
            List<Long> panelTableIdsByPanelId = panelMapper.getPanelTableIdsByPanelId(component.getPanelId());
            if (panelTableIdsByPanelId == null || !panelTableIdsByPanelId.contains(component.getComponentId())) {
                throw new BusinessException(ResponseResult.PANEL_NOT_HAVE_THIS_TABLE);
            }
            panelMapper.deletePanelTable(component);
        } else if (component.getComponentType().equals(Constant.ComponentType.MAP)) {
            // 检查仪表盘是否已包含地图
            MapData panelMapByPanelId = panelMapper.getPanelMapByPanelId(component.getPanelId());
            if (panelMapByPanelId == null) {
                throw new BusinessException(ResponseResult.PANEL_NOT_HAVE_MAP);
            }
            // 上传的地图组件id是无意义的,需要使用通过仪表盘获取的地图id
            mapMapper.deleteMap(panelMapByPanelId.getId());
            panelMapper.deletePanelMap(panelMapByPanelId.getId());
            mapMapper.deleteMapLink(panelMapByPanelId.getId());
        } else if (component.getComponentType().equals(Constant.ComponentType.MAP_LINK)) {
            // 检查是否存在地图组件
            Long mapId = panelMapper.getPanelMapIdByPanelId(component.getPanelId());
            if (mapId == null) {
                throw new BusinessException(ResponseResult.PANEL_NOT_HAVE_MAP_LINK);
            }
            mapMapper.deleteMapLink(mapId);
        } else {
            throw new BusinessException(ResponseResult.PANEL_COMPONENT_TYPE_ERROR);
        }
    }

}